﻿namespace MyWebLog.Logic.QueryProviders
{
    using DatabaseAbstraction.Interfaces;
    using DatabaseAbstraction.Models;
    using System.Collections.Generic;

    /// <summary>
    /// This class contains queries to manipulate blogs.
    /// It uses the "blog" query namespace.
    /// </summary>
    public class BlogQueryProvider : IDatabaseQueryProvider
    {
        /// <summary>
        /// The prefix for queries provided by this provider
        /// </summary>
        public string Prefix
        {
            get { return _prefix; }
            set { _prefix = value; }
        }

        private string _prefix = "blog.";

        #region Main

        /// <summary>
        /// Get the queries for blogs
        /// </summary>
        /// <param name="queries">
        /// The query library being built
        /// </param>
        public void Queries(IDictionary<string, DatabaseQuery> queries)
        {
            // Select
            queries.Add(Prefix + "get.all", GetAll());

            // Insert

            // Update

            // Delete
        }

        #endregion

        #region Select

        /// <summary>
        /// blog.get.all
        /// </summary>
        /// <returns>
        /// A populated query
        /// </returns>
        private DatabaseQuery GetAll()
        {
            return new DatabaseQuery
            {
                SQL = @"SELECT
                    blog_id, blog_name, subtitle, base_url
                FROM blog
                ORDER BY blog_name"
            };
        }

        #endregion
    }
}